﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using ReflectionStudio.Core.Events;
using System.Windows.Threading;
using System.Threading;
using DSTVKPOS;
namespace WPFExcelReport
{
  
    public class BaseVKPOSData : BaseFunction
    {
        public bool checkVK07 = true;
        SETDSTVKPOS setVK=new SETDSTVKPOS();
        public BaseVKPOSData()
            : base()
        {

        }
        public BaseVKPOSData(OracleConnection _OracleDB, IntexReptServBLClient _proxy, string userID = "        ")
            : base(_OracleDB,_proxy,userID)
        {
        }
        public BaseVKPOSData(Dictionary<string, object> DicGlobalPara)
            : base(DicGlobalPara)
        {

        }
        public DataSet GetVKKOPF(DataRow dwVKKOPF)
        {
            DataSet setReturn = new DataSet();           
            DataSet setResult = new DataSet();         
            DataTable tableLocal = null;
            DataSet setTXTKOPF = new DataSet();
            string VKPAUFNUM;
            string VKKMANDANT, VKKAUFKRS, VKKAUFLFD;

            VKKMANDANT = dwVKKOPF["VKKMANDANT"].ToString().Trim();
            VKKAUFKRS = dwVKKOPF["VKKAUFKRS"].ToString().Trim();
            VKKAUFLFD = dwVKKOPF["VKKAUFLFD"].ToString().Trim();
            try
            {
                OracleCommand or1 = OracleDB.CreateCommand();
                #region 
                //VKKMANDANT,VKKAUFKRS,VKKAUFLFD,VKKKUNDNR,KDKUNDNA,VKKVB,VKKORDER,VKKSACHBE,VKKZAHLBED,VKKBESTNR,VKKVERSART,VKKSPED 
                or1.CommandText = "SELECT K.* ,S.*,Z.ZABBEZ FROM VKKOPF K  LEFT JOIN KDSTAMM S ON VKKKUNDNR=KDKUNDNR AND VKKMANDANT=KDMANDANT"
                    + " LEFT JOIN ZABED Z ON   K.VKKMANDANT=Z.ZABMANDANT AND K.VKKZAHLBED=Z.ZABNR"
                    + " WHERE ZABSPRACHKZ='V ' AND VKKMANDANT=:VKKMANDANT AND VKKAUFKRS=:VKKAUFKRS AND VKKAUFLFD=:VKKAUFLFD AND VKKSA = '  ' ";
                    
                /*"SELECT * "
                    + " FROM VKKOPF K"
                    + " LEFT JOIN KDSTAMM ON VKKKUNDNR=KDKUNDNR AND VKKMANDANT=KDMANDANT "
                    + " WHERE VKKMANDANT=:VKKMANDANT AND VKKAUFKRS=:VKKAUFKRS AND VKKAUFLFD=:VKKAUFLFD AND VKKSA = '  ' "
                    //+" WHERE VKKMANDANT='00' AND VKKAUFKRS='C0' AND VKKAUFLFD='100227'" 
                    + " ORDER BY 1,2,3,4";
                 * */

                or1.Parameters.Add("VKKMANDANT", OracleType.NVarChar).Value = dwVKKOPF["VKKMANDANT"].ToString();
                or1.Parameters.Add("VKKAUFKRS", OracleType.NVarChar).Value = dwVKKOPF["VKKAUFKRS"].ToString();
                or1.Parameters.Add("VKKAUFLFD", OracleType.NVarChar).Value = dwVKKOPF["VKKAUFLFD"].ToString();
                #endregion
                setResult = Connect2Proxy(or1);
                DataRow dwVKPOS = setVK.VKPOS.NewVKPOSRow();
                if (setResult.Tables.Count > 0)
                {
                    tableLocal = setResult.Tables[0];
                    tableLocal.TableName = "VKKOPF";
                    setReturn.Merge(setResult);
                    foreach (DataRow dwTemp in tableLocal.Rows)
                    {
                        string KRS = dwVKKOPF["VKKAUFKRS"].ToString();
                        string LFD = dwVKKOPF["VKKAUFLFD"].ToString();
                        string VKPAUF = KRS + LFD;
                        setTXTKOPF = GetTXT(VKPAUF);
                        string TXTISIND = "";
                        string type="";
                        string lastTXTISIND = "";
                        DataRow dwTXTKON = null;
                        DataTable tbTXTKON = setTXT.TXTKON.Copy();
                        string TXTKPOS = "";
                        int pos = 1;
                        Dictionary<string, int> txtID = new Dictionary<string, int>();
                        string processed = "";
                        foreach (DataRow dwTXT in setTXTKOPF.Tables["TXTKON"].Rows)
                        {                            
                            TXTISIND = dwTXT["TXTISIND"].ToString();
                            TXTKPOS = dwTXT["TXTKPOS"].ToString();
                            if (!processed.Contains(TXTISIND + ";"))
                            {
                                processed += TXTISIND + ";";
                                dwTXTKON = tbTXTKON.NewRow();
                                tbTXTKON.Rows.Add(dwTXTKON);
                                dwTXTKON["TXTIPIND"] = TXTISIND;
                            }
                            else
                            { 
                                var query=from DataRow dw in tbTXTKON.AsEnumerable()
                                          where dw["TXTIPIND"].ToString()==TXTISIND
                                          select dw;
                                foreach (DataRow dw in query)
                                {
                                    dwTXTKON = dw;
                                }
                            } 
                           
                            if (txtID.ContainsKey(TXTISIND))
                            {
                                pos = txtID[TXTISIND];
                                pos++;
                                txtID[TXTISIND] = pos;
                            }
                            else
                            {
                                pos = 1;
                                txtID.Add(TXTISIND, pos);
                            }                          
                            TXTKPOS = Right("000" + pos.ToString()+"0", 3);
                         
                            if (tbTXTKON.Columns.Contains("TXT" + TXTKPOS))
                            {
                                dwTXTKON["TXT" + TXTKPOS] = dwTXT["TXTKTEXT"];
                            }
                           
                        }
                        setReturn.Merge(tbTXTKON);
                    } 
                } 
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        } 
        public DataSet ListVKPOS(DataRow dwVKKOPF)
        {
            DataSet set4Return = new DataSet();
            DataSet setLocal = new DataSet();
            DataSet setResult = new DataSet();
            DataSet setTemp = new DataSet();
            DataTable tableLocal = null;
            OracleCommand or1;
            string VKPNEUDAT = dwVKKOPF["VKPNEUDAT"].ToString().Trim();
            try
            {
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT VKPAUFKRS,VKPAUFLFD,VKPAUFPOS,VKPPOSTYP,VKPKDBEZ,VKPKDARTNR,VKPKDFARBNR,ROUND(VKPMENGE1*0.01,0) AS VKPMENGE1,VKPMEEH,VKPLIEFTERM"
                + ",'' AS EDIT_VK,'' AS EDIT_TE,''AS EDIT_TEM,'' AS EDIT_EK FROM VKPOS WHERE VKPSA='  ' AND VKPNEUDAT>='" + VKPNEUDAT + "'";

                setLocal = Connect2Proxy(or1);
                if (setLocal.Tables.Count > 0)
                {
                    tableLocal = setLocal.Tables[0];
                    tableLocal.TableName = "LISTVKPOS";
                    DataTable dbTmp = tableLocal.Clone();
                    dbTmp.TableName = "EDIT_VK";
                    set4Return.Merge(dbTmp);
                    dbTmp = tableLocal.Clone();
                    dbTmp.TableName = "EDIT_TE";
                    set4Return.Merge(dbTmp);
                    dbTmp = tableLocal.Clone();
                    dbTmp.TableName = "EDIT_TEM";
                    set4Return.Merge(dbTmp);
                    dbTmp = tableLocal.Clone();
                    dbTmp.TableName = "EDIT_EK";
                    set4Return.Merge(dbTmp);
                    dbTmp.TableName = "EDIT_TD";
                    set4Return.Merge(dbTmp);
                    byte[] b;
                    string value;
                    string sTemp = "";
                    string Column = "";
                    string KDKUNDNA;
                    string User = "";
                    bool flagremoved = false;
                    int maxstep = 0;
                    foreach (DataRow dwTemp in tableLocal.Rows)
                    {
                        Column = "VKPKDFARBNR";
                        #region
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dwTemp[Column].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dwTemp[Column] = value;
                        #endregion
                        Column = "VKPKDARTNR";
                        #region
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dwTemp[Column].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dwTemp[Column] = value;
                        #endregion
                        Column = "VKPKDBEZ";
                        #region
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dwTemp[Column].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dwTemp[Column] = value;
                        #endregion
                        flagremoved = false;
                        maxstep = 0;
                        string KRS = dwTemp["VKPAUFKRS"].ToString().Trim();
                        string LFD = dwTemp["VKPAUFLFD"].ToString().Trim();
                        string POS = "000";
                        string VKPAUF = KRS + LFD + POS;
                        string TXTISIND = VKPAUF + "BEST" + "                                             ";
                        #region EDIT_VK
                        or1.CommandText = "SELECT TXTKTEXT FROM TXTIND T "
                        + " LEFT JOIN TXTKON N ON T.TXTIMANDANT=N.TXTKMANDANT  AND TXTIPIND=TXTKPIND AND TXTKPOS='310'"
                        + "WHERE TXTIMANDANT='00' AND TXTITXTART='VKT' AND TXTISIND = '" + TXTISIND + "'";
                        setResult = Connect2Proxy(or1);
                        if (setResult.Tables.Count > 0)
                        {
                            if (setResult.Tables[0].Rows.Count > 0)
                            {
                                User = this.Left(setResult.Tables[0].Rows[0][0].ToString().Trim() + "        ", 8);
                                if (User.Trim() != "")
                                {
                                    dwTemp["EDIT_VK"] = User;
                                    maxstep = 1;
                                }
                            }
                        }

                        POS = dwTemp["VKPAUFPOS"].ToString().Trim();
                        VKPAUF = KRS + LFD + POS;
                        TXTISIND = VKPAUF + "BEST" + "                                             ";
                        or1.CommandText = "SELECT TXTKPOS, TXTKTEXT FROM TXTIND T "
                      + " LEFT JOIN TXTKON N ON T.TXTIMANDANT=N.TXTKMANDANT  AND TXTIPIND=TXTKPIND AND TXTKPOS in ('310','320','330')"
                      + "WHERE TXTIMANDANT='00' AND TXTITXTART='VKT' AND TXTISIND = '" + TXTISIND + "'";
                        setResult = Connect2Proxy(or1);
                        if (setResult.Tables.Count > 0)
                        {
                            foreach (DataRow dwX in setResult.Tables[0].Rows)
                            {
                                User = this.Left(dwX[1].ToString().Trim() + "        ", 8);
                                string UserType = dwX[0].ToString().Trim();
                                if (User.Trim() != "")
                                {
                                    flagremoved = true;
                                    switch (UserType)
                                    {
                                        case "310":
                                            maxstep = 2;
                                            dwTemp["EDIT_TE"] = User;
                                            break;
                                        case "320":
                                            dwTemp["EDIT_TEM"] = User;
                                            maxstep = 3;
                                            break;
                                        case "330":
                                            maxstep = 4;
                                            dwTemp["EDIT_EK"] = User;
                                            break;
                                    }
                                }
                            }
                        }
                        #endregion
                        if (maxstep == 0)
                        {
                            set4Return.Tables["EDIT_TD"].Rows.Add(dwTemp.ItemArray);
                            continue;
                        }
                        if (maxstep == 4)
                        {
                            set4Return.Tables["EDIT_EK"].Rows.Add(dwTemp.ItemArray);
                            continue;
                        }
                        if (maxstep == 3)
                        {
                            set4Return.Tables["EDIT_TEM"].Rows.Add(dwTemp.ItemArray);
                            continue;
                        }
                        if (maxstep == 2)
                        {
                            set4Return.Tables["EDIT_TE"].Rows.Add(dwTemp.ItemArray);
                            continue;
                        }
                        if (maxstep == 1)
                        {
                            set4Return.Tables["EDIT_VK"].Rows.Add(dwTemp.ItemArray);
                            continue;
                        }

                    }
                    set4Return.Merge(setLocal);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return set4Return;
        }
        public DataSet GetVKPOS(DataRow dwVKKOPF)
        {
            DataSet set4Return = new DataSet();
            DataSet setLocal = new DataSet();
            DataSet setResult = new DataSet();
            DataSet setTemp = new DataSet();
            DataTable tableLocal = null;
            try
            {
                OracleCommand or1 = OracleDB.CreateCommand();
                #region
                /*VKPAUFMART0114	
VKPVERPART 0209
VKPSTLGV
VKPSTLGB
VKPTSTLG
VKPMGV	
VKPMGB*/
                or1.CommandText = "SELECT VKPMANDANT,KDNAME1,VKKBESTNR,VKKBESTDAT,VKPAUFKRS,VKPAUFLFD,VKPAUFPOS"
                    + ",VKPSA,VKPEZEIT,VKPAENDBEN,VKPAUFMART,VKPVERPART"
                    + ",VKPAENDDAT,VKPNEUBEN,VKPNEUDAT,VKPPOSTYP,VKPARTST,VKPTSTLG,VKPSTLGB,VKPSTLGV"
                    + ",VKPKOLL,VKPART,VKPFARBE,VKPKDFARBNR,VKPMGB,VKPMGV"
                + ",VKPVERPART||':'||SUBSTR(M.SDDATEN,2,10) AS VKPVERPART,VKPAUFMART||':'||SUBSTR(P.SDDATEN,2,10) AS VKPVERPART"
                    + ",VKPKDARTNR,VKPKDBEZ,VKPMENGE1,VKPMEEH,VKPMEEHFKT"
                    + ",VKPMENGE1T1,VKPMENGE1T2,VKPLIEFTERM,VKPVB,VKPPREH,VKPPREIS,VKPWVTERM"
                    + ",VKPZUSATZ "
                    + " FROM VKPOS P JOIN VKKOPF ON   VKKMANDANT=VKPMANDANT AND VKKAUFKRS=VKPAUFKRS AND VKKAUFLFD=VKPAUFLFD"
                    + " LEFT JOIN KDSTAMM ON VKKKUNDNR=KDKUNDNR AND VKKMANDANT=KDMANDANT"
                    + " LEFT JOIN SDDAT M ON VKPMANDANT = SUBSTR(M.SDKEY,1,2)  AND VKPAUFMART = SUBSTR(M.SDKEY,3,3) AND M.SDSA = '0114' AND SUBSTR(M.SDKEY,24,1) = 'V'"
                    + "LEFT JOIN SDDAT P ON VKPMANDANT = SUBSTR(P.SDKEY,1,2)  AND VKPVERPART = SUBSTR(P.SDKEY,3,3) AND P.SDSA = '0209' AND SUBSTR(P.SDKEY,24,1) = 'V'"
                + " WHERE VKPMANDANT=:VKPMANDANT AND VKPSA='  ' AND VKKSA = '  ' AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD"
                + " ORDER BY VKPAUFKRS,VKPAUFLFD,VKPAUFPOS ";
                or1.CommandText = "SELECT VKPMANDANT,KDNAME1,VKKBESTNR,VKKBESTDAT,VKPAUFKRS,VKPAUFLFD,VKPAUFPOS"
    + ",VKPSA,VKPEZEIT,VKPAENDBEN,VKPAUFMART,VKPVERPART"
    + ",VKPAENDDAT,VKPNEUBEN,VKPNEUDAT,VKPPOSTYP,VKPARTST,VKPTSTLG,VKPSTLGB,VKPSTLGV"
    + ",VKPKOLL,VKPART,VKPFARBE,VKPKDFARBNR,VKPMGB,VKPMGV"
+ ",VKPVERPART||':'||SUBSTR(M.SDDATEN,2,10) AS VKPVERPART,VKPAUFMART||':'||SUBSTR(P.SDDATEN,2,10) AS VKPVERPART"
    + ",VKPKDARTNR,VKPKDBEZ,VKPMENGE1,VKPMEEH,VKPMEEHFKT"
    + ",VKPMENGE1T1,VKPMENGE1T2,VKPLIEFTERM,VKPVB,VKPPREH,VKPPREIS,VKPWVTERM"
    + ",VKPZUSATZ "
    + " FROM VKPOS P JOIN VKKOPF ON   VKKMANDANT=VKPMANDANT AND VKKAUFKRS=VKPAUFKRS AND VKKAUFLFD=VKPAUFLFD"
    + " LEFT JOIN KDSTAMM ON VKKKUNDNR=KDKUNDNR AND VKKMANDANT=KDMANDANT"
    + " LEFT JOIN SDDAT M ON VKPMANDANT = SUBSTR(M.SDKEY,1,2)  AND VKPAUFMART = SUBSTR(M.SDKEY,3,3) AND M.SDSA = '0114' AND SUBSTR(M.SDKEY,24,1) = 'V'"
    + "LEFT JOIN SDDAT P ON VKPMANDANT = SUBSTR(P.SDKEY,1,2)  AND VKPVERPART = SUBSTR(P.SDKEY,3,3) AND P.SDSA = '0209' AND SUBSTR(P.SDKEY,24,1) = 'V'"
+ " WHERE VKPMANDANT=:VKPMANDANT AND VKPSA='  ' AND VKKSA = '  ' AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD"
+ " ORDER BY VKPAUFKRS,VKPAUFLFD,VKPAUFPOS ";
                or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwVKKOPF["VKKMANDANT"].ToString();
                or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwVKKOPF["VKKAUFKRS"].ToString();
                or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwVKKOPF["VKKAUFLFD"].ToString();

                #endregion
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tableLocal = setResult.Tables[0];
                    tableLocal.TableName = "VKPOS"; 
                }
                set4Return.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return set4Return;
        }
        public DataSet QueryWDECK(DataRow dwVKKOPF, string WDSA = "K", string WDUPOS = "00")
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            DataSet setTemp = new DataSet();
            DataTable tableLocal = null;

            OracleCommand or1;
            try
            {
                #region==================SELECT=================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT * FROM WDECK "
                + " WHERE WDMANDANT=:WDMANDANT AND WDSA=:WDSA AND WDUPOS=:WDUPOS "
                + " AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD";
                or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwVKKOPF["VKKMANDANT"];
                or1.Parameters.Add("WDSA", OracleType.NVarChar).Value = WDSA;
                or1.Parameters.Add("WDUPOS", OracleType.NVarChar).Value = WDUPOS;
                or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwVKKOPF["VKKAUFKRS"];
                or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwVKKOPF["VKKAUFLFD"];              
                #endregion
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tableLocal = setResult.Tables[0];
                    tableLocal.TableName = "WDECK";
                } 
                setReturn.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
       public DataSet QueryWDART(string WDPRART,string WDPRVAR)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            DataSet setTemp = new DataSet();
            DataTable tableLocal = null;
            OracleCommand or1;
            try
            {
                string WADART, WADVAR; 

                #region
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT WAART,WAVAR,WABEZ FROM WASTAMM"
                + " WHERE WAART = '" + WDPRART + "' AND WAVAR='" + WDPRVAR + "'"
                + " ORDER BY 2,1";
                #endregion
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tableLocal = setResult.Tables[0];
                    tableLocal.TableName = "WASTAMM";
                } 
                setReturn.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet QueryWDART(DataRow dwVAFARBEN)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            DataSet setTemp = new DataSet();
            DataTable tableLocal = null;
            OracleCommand or1;
            try
            {
                string WADART, WADVAR;

                WADART = dwVAFARBEN["VAFPART"].ToString();
                WADVAR = dwVAFARBEN["VAFPVAR"].ToString(); 
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT WAART,WAVAR,WABEZ FROM WASTAMM"
                + " WHERE WADART = '" + WADART + "' AND WADVAR='" + WADVAR + "'"
                + " ORDER BY 2,1"; 
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tableLocal = setResult.Tables[0];
                    tableLocal.TableName = "WASTAMM";
                }

                setReturn.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet QueryVA0710(DataRow dwVKPOS)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            DataSet setTemp = new DataSet();
            DataTable tableLocal = null;
            OracleCommand or1;
            try
            {
                #region
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT * FROM VAART "
                + " WHERE VAAMANDANT=:VAAMANDANT AND VAAKOLL=:VAAKOLL AND VAAART=:VAAART";

                or1.Parameters.Add("VAAMANDANT", OracleType.NVarChar).Value = dwVKPOS["VKPMANDANT"];
                or1.Parameters.Add("VAAKOLL", OracleType.NVarChar).Value = dwVKPOS["VKPKOLL"];
                or1.Parameters.Add("VAAART", OracleType.NVarChar).Value = dwVKPOS["VKPART"];

                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tableLocal = setResult.Tables[0];
                    tableLocal.TableName = "VAART";
                }
                setReturn.Merge(setResult);
                #endregion

                #region
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT * FROM VAFARBEN "
                + " WHERE VAFMANDANT=:VAFMANDANT AND VAFKOLL=:VAFKOLL AND VAFART=:VAFART AND VAFFARBE=:VAFFARBE";

                or1.Parameters.Add("VAFMANDANT", OracleType.NVarChar).Value = dwVKPOS["VKPMANDANT"];
                or1.Parameters.Add("VAFKOLL", OracleType.NVarChar).Value = dwVKPOS["VKPKOLL"];
                or1.Parameters.Add("VAFART", OracleType.NVarChar).Value = dwVKPOS["VKPART"];
                or1.Parameters.Add("VAFFARBE", OracleType.NVarChar).Value = dwVKPOS["VKPFARBE"];

                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tableLocal = setResult.Tables[0];
                    tableLocal.TableName = "VAFARBEN";
                }
                setReturn.Merge(setResult);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet GetDATALINK(DataRow dwVKKOPF)
        {
            DataSet set4Return = new DataSet(); 
            DataSet setResult = new DataSet(); 
            DataTable tableLocal = null;
            string VKKOPF="";
            try
            {
                OracleCommand or1 = OracleDB.CreateCommand();
               
                VKKOPF=dwVKKOPF["VKKMANDANT"].ToString()
                    +"  "
                    +dwVKKOPF["VKKAUFKRS"].ToString()
                    +dwVKKOPF["VKKAUFLFD"].ToString();
                or1.CommandText = "SELECT DLKKEY,SUBSTR(DLKKEY,0,2) AS MAND,SUBSTR(DLKKEY,5,2) AS KRS,SUBSTR(DLKKEY,7,6) AS LFD,SUBSTR(DLKKEY,13,3) AS POS,DLDPPNR,DLDPPFAD,DLDPNAME"
                +" FROM DLKOPF,DLDPOS"
                    +" WHERE DLKNAME='VKPOS' AND DLKPKEY=DLDPPKEY "
                    +" AND DLKKEY LIKE '"+VKKOPF+"%'";  
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tableLocal = setResult.Tables[0];
                    tableLocal.TableName = "DLDPOS";
                }
                set4Return.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return set4Return;
        }
        public void UpdateWDECK(DataRow dwWDECK, DataRow dwWASTAMM)
        {
            OracleCommand or1 = OracleDB.CreateCommand();
            try
            {
               
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE WDECK SET WDPRART=:WDPRART,WDPRVAR=:WDPRVAR,WDKUNDNR='00000000'"
                    + " WHERE   "
                + "  WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS AND WDUPOS=:WDUPOS ";
                or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwWDECK["WDMANDANT"].ToString();
                or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwWDECK["WDAUFKRS"].ToString();
                or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwWDECK["WDAUFLFD"].ToString();
                or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwWDECK["WDAUFPOS"].ToString();
                or1.Parameters.Add("WDUPOS", OracleType.NVarChar).Value = dwWDECK["WDUPOS"].ToString(); 
                or1.Parameters.Add("WDPRART", OracleType.NVarChar).Value = dwWASTAMM["WAART"].ToString();
                or1.Parameters.Add("WDPRVAR", OracleType.NVarChar).Value = dwWASTAMM["WAVAR"].ToString();
                setResult = Connect2Proxy(or1);
                 
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public virtual DataSet GetData(DataRow dwUI)
        {
            try
            {
            }
            catch (Exception ex)
            {
                Tracer.Error(ABPOS + ex.StackTrace, ex);
            }
            return setReturn;
        }
    }
}